/*
 * Copyright (c) 2022 HiSilicon (Shanghai) Technologies CO., LIMITED.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef LBPH_TRACKING_H
#define LBPH_TRACKING_H

#include <pthread.h>
#include "svp_nnie_application.h"

#if __cplusplus
extern "C" {
#endif

#define LBPH_IMG_WIDTH      64
#define LBPH_IMG_HEIGHT     64

typedef struct s_sIntRectBox {
    int xmin;
    int xmax;
    int ymin;
    int ymax;
} IntRectBox;

typedef struct hiSAMPLE_IVE_LBPH_S {
    IVE_DST_IMAGE_S stGrayImg;      // gray reszie img 64 x 64
    IVE_DST_IMAGE_S stEqualHistImg; // EqualizeHist
    IVE_EQUALIZE_HIST_CTRL_S stEaualHistCtrl;
    IVE_DST_IMAGE_S stLbpImg;       // lbp img
    IVE_LBP_CTRL_S stLbpCtrl;
} SAMPLE_IVE_LBPH_S;

typedef struct hiSAMPLE_IVE_FEATURE_MATCH_S {
    IVE_MEM_INFO_S stMatchMem;      // Match img feature data
    IVE_MEM_INFO_S stFeatureMem;    // Match img feature data
    HI_U8 grid_w;                   // block grid width
    HI_U8 grid_h;                   // block grid height
    HI_BOOL isTaskReady;
    HI_BOOL isNewMatch;
    HI_BOOL isUpdate;
    HI_BOOL isProcess;
    RectBox bBox;
    HI_FLOAT score;
} SAMPLE_IVE_FEATURE_MATCH_S;

HI_VOID SAMPLE_IVE_LBPH_HandleSig( void );

HI_VOID IVE_LBPH_READY_FOR_TASK(VIDEO_FRAME_INFO_S *frm, SVP_NNIE_YOLOV5_BBOX_S *res, HI_BOOL isNewMatch);

HI_BOOL IVE_LBPH_RETURN_RESULT(RectBox *bbox, HI_FLOAT *score, HI_BOOL *isNewTemp);

HI_VOID* IveLbphProcess(HI_VOID* pArgs);

HI_VOID SAMPLE_IVE_LBPH_Stop( void );

#ifdef __cplusplus
}
#endif
#endif